#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import mysql.connector

def get_connector():
    conn = mysql.connector.connect(user='root', password='root', database='social')
    return conn

def close_connector(conn):
    conn.close()

def op_table(conn, sql_str):
    cursor = conn.cursor()
    cursor.execute(sql_str)
    cursor.close()
    
    
    
def insert(conn, sql_str, sql_data=''):
    cursor = conn.cursor()
    cursor.execute(sql_str, sql_data)
    conn.commit()
    cursor.close()
    
def query(conn, sql_str, sql_data):
    cursor = conn.cursor()
    cursor.execute(sql_str, sql_data)
    return cursor
